/*--------------------------------------------------------------
 * File: demo58.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 查找字符在字符串中出现的次数
 * Version 0.1
 * Date 2022-08-19 
 * 
 * @copyright Copyright (c) 2022
 * 
----------------------------------------------------------------*/
#include <stdio.h>
int main(int argc, char const *argv[])
{
    char str[1000] = {0};
    char ch = 0;
    int i, frequency = 0;

    printf("输入字符串：");
    fgets(str, (sizeof(str) / sizeof(str[0])), stdin);

    printf("输入要查找的字符：");
    scanf("%c",&ch);

    for(i=0; str[i]!='\0'; i++)
    {
        if(ch == str[i])
        {
            frequency++;
        }
    }
    printf("字符%c在字符串中出现的次数为%d\n", ch, frequency);
    return 0;
}

